﻿Imports System.Data.Linq
Imports System.Linq

Public Class AdvanceDriverRepository
    Private dc As New TanNamChinhDataContext

    Public Sub New()
        dc = GeneralClassDAL.dc
    End Sub

    Public Function SelectAllRecord() As IQueryable(Of tblAdvanceDriver)
        Dim companies = From p In dc.tblAdvanceDrivers
                        Select p
        Return companies
    End Function

    Public Function SelectRecordById(ByVal id As Integer) As tblAdvanceDriver
        Return dc.tblAdvanceDrivers.SingleOrDefault(Function(p As tblAdvanceDriver) p.ID_AdvanceDriver = id)
    End Function

    Public Sub Insert(ByVal obj As tblAdvanceDriver)
        dc.tblAdvanceDrivers.InsertOnSubmit(obj)
        dc.SubmitChanges()
    End Sub

    Public Sub Update(ByVal obj As tblAdvanceDriver)
        dc.Refresh(RefreshMode.KeepChanges, obj)
        dc.SubmitChanges(ConflictMode.ContinueOnConflict)
    End Sub

    Public Sub Delete(ByVal obj As tblAdvanceDriver)
        dc.tblAdvanceDrivers.DeleteOnSubmit(obj)
        dc.SubmitChanges()
    End Sub
End Class
